<template>
  <view class="member-page">
    <!-- 用户资料区域 -->
    <view class="profile-section">
      <view class="avatar-container">
        <view class="avatar-placeholder"> </view>
      </view>
      <view class="user-info">
        <view class="username">流浪的小行星圆舞曲</view>
        <view class="user-id">重庆-6559</view>
      </view>
    </view>

    <!-- 会员等级区域 -->
    <view class="member-level-section">
      <view class="level-info">
        <view class="level-text">V1 普通会员</view>
        <view class="level-progress">(距离升下一级还差500成长值)</view>
      </view>
      <view class="level-badge">
        <view class="badge-icon">V</view>
      </view>
      <view class="more-link">查看更多></view>
    </view>

    <!-- 账户资产区域 -->
    <view class="assets-section">
      <view class="recharge-button">点击充值</view>
      <view class="assets-grid">
        <view class="asset-item">
          <view class="asset-value">0</view>
          <view class="asset-label">金币</view>
        </view>
        <view class="asset-item">
          <view class="asset-value">0</view>
          <view class="asset-label">积分</view>
        </view>
        <view class="asset-item">
          <view class="asset-value">0</view>
          <view class="asset-label">券</view>
        </view>
      </view>
    </view>

    <!-- 功能按钮区域 -->
    <view class="action-buttons">
      <view class="action-item" @click="handleInvite">
        <text>邀请有礼</text>
      </view>
      <view class="action-item" @click="handleSavePoints">
        <text>存积分</text>
      </view>
      <view class="action-item" @click="handleOrderList">
        <text>订单列表</text>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from "vue";

// 响应式数据
const assets = ref({
  coins: 0,
  points: 0,
  coupons: 0,
});

// 方法
const handleRecharge = () => {
  console.log("点击充值");
  uni.showToast({
    title: "充值功能开发中",
    icon: "none",
  });
};

const handleInvite = () => {
  console.log("邀请有礼");
  uni.showToast({
    title: "邀请有礼功能开发中",
    icon: "none",
  });
};

const handleSavePoints = () => {
  console.log("存积分");
  uni.showToast({
    title: "存积分功能开发中",
    icon: "none",
  });
};

const handleOrderList = () => {
  console.log("订单列表");
  uni.showToast({
    title: "订单列表功能开发中",
    icon: "none",
  });
};

const navigateTo = (url) => {
  if (url !== "/pages/Member/index") {
    uni.switchTab({
      url: url,
    });
  }
};
</script>

<style lang="scss">
.member-page {
  min-height: 100vh;
  background-color: #000000;
  color: #ffffff;
  position: relative;
  padding-bottom: 120rpx; // 为底部导航留出空间
}

/* 顶部导航栏 */
.top-header {
  height: 88rpx;
  background-color: #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30rpx;

  .header-title {
    font-size: 36rpx;
    font-weight: 500;
    color: #ffffff;
  }

  .header-actions {
    display: flex;
    gap: 20rpx;

    .action-icon {
      width: 40rpx;
      height: 40rpx;
      border-radius: 50%;
      background-color: #3a3a3a;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 24rpx;
      color: #ffffff;
    }
  }
}

/* 用户资料区域 */
.profile-section {
  background-color: #000000;
  padding: 40rpx 30rpx;
  display: flex;
  align-items: center;

  .avatar-container {
    margin-right: 30rpx;

    .avatar-placeholder {
      width: 100rpx;
      height: 100rpx;
      border-radius: 50%;
      background-color: #f0f0f0;
      display: flex;
      align-items: center;
      justify-content: center;

      .avatar-icon {
        font-size: 40rpx;
        color: #666666;
      }
    }
  }

  .user-info {
    flex: 1;

    .username {
      font-size: 40rpx;
      font-weight: bold;
      color: #ffc300;
      margin-bottom: 10rpx;
    }

    .user-id {
      font-size: 28rpx;
      color: #cccccc;
    }
  }
}

/* 会员等级区域 */
.member-level-section {
  background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
  margin: 0 30rpx 30rpx;
  border-radius: 20rpx;
  padding: 30rpx;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;

  .level-info {
    flex: 1;

    .level-text {
      font-size: 48rpx;
      font-weight: bold;
      color: #333333;
      margin-bottom: 10rpx;
    }

    .level-progress {
      font-size: 24rpx;
      color: #999999;
    }
  }

  .level-badge {
    width: 80rpx;
    height: 80rpx;
    background-color: #c0c0c0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 20rpx;

    .badge-icon {
      font-size: 48rpx;
      font-weight: bold;
      color: #ffffff;
    }
  }

  .more-link {
    position: absolute;
    top: 20rpx;
    right: 20rpx;
    font-size: 24rpx;
    color: #999999;
  }
}

/* 账户资产区域 */
.assets-section {
  background: linear-gradient(135deg, #8b4513 0%, #a0522d 100%);
  margin: 0 30rpx 30rpx;
  border-radius: 20rpx;
  padding: 40rpx 30rpx 30rpx;
  position: relative;

  .recharge-button {
    position: absolute;
    top: -20rpx;
    left: 50%;
    transform: translateX(-50%);
    background-color: #ffc300;
    color: #000000;
    padding: 10rpx 40rpx;
    border-radius: 30rpx;
    font-size: 24rpx;
    font-weight: 500;
  }

  .assets-grid {
    display: flex;
    justify-content: space-around;
    margin-top: 20rpx;

    .asset-item {
      text-align: center;

      .asset-value {
        font-size: 60rpx;
        font-weight: bold;
        color: #ffffff;
        margin-bottom: 10rpx;
      }

      .asset-label {
        font-size: 28rpx;
        color: #ffffff;
      }
    }
  }
}

/* 功能按钮区域 */
.action-buttons {
  margin: 0 30rpx 30rpx;

  .action-item {
    background-color: #000000;
    color: #ffffff;
    padding: 30rpx;
    margin-bottom: 10rpx;
    border-radius: 10rpx;
    text-align: center;
    font-size: 32rpx;

    &:active {
      background-color: #1a1a1a;
    }
  }
}

/* 底部导航栏 */
.bottom-navigation {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120rpx;
  background-color: #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 20rpx;

  .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;

    &.active {
      .nav-label {
        color: #ffc300;
      }
    }

    .nav-icon {
      width: 40rpx;
      height: 40rpx;
      margin-bottom: 8rpx;
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center;

      &.home-icon {
        background-image: url("/static/images/SolarHomeAngleBold.png");
      }

      &.desktop-icon {
        background-image: url("/static/images/SolarWidget5Linear.png");
      }

      &.ranking-icon {
        background-image: url("/static/images/SolarRankingLinear.png");
      }

      &.member-icon {
        background-image: url("/static/images/SolarUserBold.png");
      }
    }

    .nav-label {
      font-size: 24rpx;
      color: #ffffff;

      &.active {
        color: #ffc300;
      }
    }
  }
}

/* 响应式适配 */
@media (max-width: 750rpx) {
  .member-page {
    padding: 0 20rpx 120rpx;
  }

  .profile-section,
  .member-level-section,
  .assets-section,
  .action-buttons {
    margin-left: 20rpx;
    margin-right: 20rpx;
  }
}
</style>
